//
//  YYJ_BaseButton.m
//  ANDA_Club
//
//  Created by 晏袁杰 on 2021/4/28.
//  Copyright © 2021 Lonely`yyj. All rights reserved.
//

#import "YYJ_BaseButton.h"

@implementation YYJ_BaseButton

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/
-(void)layoutSubviews{
    [super layoutSubviews];
    if (self.isRound) {
        CGFloat xxx = CGRectGetWidth(self.frame);
        if (xxx>CGRectGetHeight(self.frame)) {
            xxx = CGRectGetHeight(self.frame);
        }
        self.layer.cornerRadius = xxx/2.0f;
    }else{
        self.layer.cornerRadius = self.cornerRadius;
    }
}
-(void)setIsRound:(BOOL)isRound{
    _isRound = isRound;
    [self layoutSubviews];
}
-(void)setCornerRadius:(CGFloat)cornerRadius{
    _cornerRadius = cornerRadius;
    [self layoutSubviews];
}
-(void)setBorderWidth:(CGFloat)borderWidth{
    _borderWidth = borderWidth;
    self.layer.borderWidth = borderWidth;
}
-(void)setBorderColor:(UIColor *)borderColor{
    _borderColor = borderColor;
    self.layer.borderColor = borderColor.CGColor;
}
- (void)setLocalizedKey:(NSString *)LocalizedKey{
    _LocalizedKey = LocalizedKey;
    [self setTitle:Anda_locForKey(LocalizedKey) forState:UIControlStateNormal];
}
-(void)setSelectedKey:(NSString *)SelectedKey{
    _SelectedKey = SelectedKey;
    [self setTitle:Anda_locForKey(SelectedKey) forState:UIControlStateSelected];
}
@end
